package com.jueling.culture.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author linp
 * @date 2018/11/5
 */
public class StringUtil {

    /**
     * 空格回车
     */
    public static Pattern p = Pattern.compile("\\s{2,}|\t|\r|\n");

    /**
     * 判断是否为空串
     * @param str
     * @return
     */
    public static boolean isEmptyStr(String str){
        if(null == str || "".equals(str) || ("null").equals(str)){
            return true;
        }
        return false;
    }

    /**
     * 判断不是空串
     * @param str
     * @return
     */
    public static boolean isNotEmptyStr(String str){
        return !isEmptyStr(str);
    }
    /**
     * 去除空格和回车
     * @param str
     * @return
     */
    public static String replaceBlankSpace(String str) {
        String destination = "";
        if (str!=null) {
            Matcher m = p.matcher(str);
            destination = m.replaceAll("");
        }
        return destination;
    }

}
